<template>
  <div>
    <nav-bar title="我的项目"></nav-bar>
    <div class="maxinBox">
      <van-cell v-for="(item, index) in projectList" :key="index" :title="item.projectName" is-link @click="projectDetails(item)" />
    </div>
  </div>
</template>

<script>
  import myAPI from '../../../api/myAPI.js'
  export default {
    data() {
      return {
        projectList: []
      }
    },
    methods:{
      // 获取项目列表
      getProjectList() {
        myAPI.getProjectList().then(res => {
          this.projectList = res.switchProjectVos
        })
      },
      // 项目详情
      projectDetails (data) {
        localStorage.setItem('projectData', JSON.stringify(data))
        this.$router.push({
          name: 'ProjectDetails'
        })
      }
    },
    mounted() {
      this.getProjectList()
    }
  }
</script>
